<template>
	<view class="content-box">
		<view class="content">
			维度：{{location.x}}
		</view>
		<view class="content">
			经度：{{location.y}}
		</view>
		<view class="content">
			定位时间：{{formatParamTime(location.time, 'datetime')}}
		</view>
		<u-button class="buttons" @click="upData" color="#2d7ffd">更新位置</u-button>
	</view>
</template>

<script>
	import {
		mapActions,
		mapGetters,
	} from "vuex"
	export default {
		computed: {
			...mapGetters(["location"])
		},
		methods: {
			async upData() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				try {
					const res = await this.$store.dispatch('user/getUserLocation', 'btn')
					uni.hideLoading()
				} catch (err) {
					uni.hideLoading()
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content-box {
		position: absolute;
		inset: 0;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		color: #000;
		font-size: 16px;

		.buttons {
			margin-top: 40rpx;
			width: 60%
		}
	}
</style>